package com.yuke.cloud.service.omc.job;

import java.security.KeyFactory;
import java.security.spec.X509EncodedKeySpec;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.yuke.cloud.common.util.RedisKeyUtil;
import com.yuke.cloud.service.omc.config.Quartz;
import com.yuke.cloud.service.omc.payUtil.Base64;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import javax.crypto.Cipher;

public class Test {
    public void go() throws Exception {
        // 首先，必需要取得一个Scheduler的引用
        SchedulerFactory sf = new StdSchedulerFactory();
        Scheduler sched = sf.getScheduler();
        // jobs可以在scheduled的sched.start()方法前被调用
        //构建job信息
        JobDetail build = JobBuilder.newJob(myJob.class).withIdentity("job2", "jobGroup2").build();
        //表达式调度构建器（任务执行时间）
        /*CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(Quartz.time);
        CronTrigger build1 = TriggerBuilder.newTrigger().withIdentity("trigger1", "triggerGroup1").startNow().withSchedule(cronScheduleBuilder).build();*/
        Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger2", "triggerGroup2").startNow().withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(1).repeatForever()).build();


        Date date = sched.scheduleJob(build, trigger);
        SimpleDateFormat sdf=new SimpleDateFormat("YYYY-MM-dd HH-mm-ss");
        System.out.println(build.getKey() + " 已被安排执行时间:" + sdf.format(date) + "");
        sched.start();
        try {
            // 主线程等待一分钟
            Thread.sleep(10L * 1000L);
        } catch (Exception e) {
        }
        // 关闭定时调度，定时器不再工作
        sched.shutdown(true);
    }

    public static void main(String[] args) throws Exception {

        byte[] buffer = Base64.decode("");
        KeyFactory rsa = KeyFactory.getInstance("RSA");
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(buffer);
        //rsa.generatePublic(rsa);
        Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding");

    }







}

